package com.qk.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qk.PageResult;
import com.qk.dto.CustomersDto;
import com.qk.entity.Customer;
import com.qk.mapper.CustomerMapper;
import com.qk.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public PageResult<Customer> ListCustomers(CustomersDto customersDto) {
        Page<Customer> page = this.customerMapper.listCustomers(new Page<Customer>(customersDto.getPage(), customersDto.getPageSize()), customersDto);
        return new PageResult<>(page.getTotal(), page.getRecords());
    }
}
